//
//  FFRedPacketsVM.m
//  LiMaoRedPackets
//
//  Created by JayLuo on 2020/9/10.
//

#import "FFRedPacketsVM.h"

@implementation FFRedPacketsVM

- (AnyPromise *)redpacketsCreate:(FFRedPacketsReq *)req {
    return [[WKAPIClient sharedClient] POST:[NSString stringWithFormat:@"redpackets"] parameters:[req toMap:ModelMapTypeAPI]];
}

@end

@implementation FFRedPacketsReq

- (NSDictionary *)toMap:(ModelMapType)type {
    return @{
        @"amount":@(self.amount),
        @"blessing": self.blessing?:@"",
        @"num":@(self.num),
        @"type": @(self.type),
        @"scene_id": self.sceneID?:@"",
        @"scene_type": @(self.sceneType)
    };
}

@end

@implementation FFRedPacketsResp

+ (FFRedPacketsResp *)fromMap:(NSDictionary *)dictory type:(ModelMapType)type {
    FFRedPacketsResp *resp = [FFRedPacketsResp new];
    resp.redpacket_no = dictory[@"redpacket_no"]?:@"";
    resp.status = dictory[@"status"]?[dictory[@"status"] integerValue]:-1;
    resp.msg = dictory[@"msg"]?:@"";
    return resp;
}

@end
